/* Copyright 2008 Bas van den Berg
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef WORLD_H
#define WORLD_H

#include "EventServer.h"
#include "AreaBuilder.h"
#include "KillStats.h"

namespace Chronos {

class Session;
class TaskQueue;
class Area;
class MudPlayer;
class StringBuilder;

class World : public EventListener {
public:
    World(EventServer& eventServer_, TaskQueue& taskQueue);
    ~World();

    void notify(Event::EventType event, Session& session);
    void load();
	
    void movePlayer(MudPlayer& player, int newAreaID, int newRoomID,
    const std::string& arriveMsg, const std::string& leaveMsg);

    const Area* findArea(int areaID) const;
    void printAreas(StringBuilder& buffer) const;
    void printStatus(StringBuilder& buffer) const;

    KillStats& getKills();
private:
    Area* getArea(int areaID) const;
    void addPlayer(Session& session);
    void removePlayer(Session& session);

    EventServer& eventServer;

    typedef std::map<int, Area*> Areas;
    typedef Areas::const_iterator AreasConstIter;
    Areas areas;

    AreaBuilder builder;

    KillStats kills;

    World(const World&);
    World& operator=(const World&);
};

}

#endif

